// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#include <pollux/dwio/common/options.h>

namespace kumo::pollux::dwio::common {
    FileFormat toFileFormat(std::string_view s) {
        if (s == "dwrf") {
            return FileFormat::DWRF;
        } else if (s == "rc") {
            return FileFormat::RC;
        } else if (s == "rc:text") {
            return FileFormat::RC_TEXT;
        } else if (s == "rc:binary") {
            return FileFormat::RC_BINARY;
        } else if (s == "text") {
            return FileFormat::TEXT;
        } else if (s == "json") {
            return FileFormat::JSON;
        } else if (s == "parquet") {
            return FileFormat::PARQUET;
        } else if (s == "nimble" || s == "alpha") {
            return FileFormat::NIMBLE;
        } else if (s == "orc") {
            return FileFormat::ORC;
        } else if (s == "sst") {
            return FileFormat::SST;
        }
        return FileFormat::UNKNOWN;
    }

    std::string_view toString(FileFormat fmt) {
        switch (fmt) {
            case FileFormat::DWRF:
                return "dwrf";
            case FileFormat::RC:
                return "rc";
            case FileFormat::RC_TEXT:
                return "rc:text";
            case FileFormat::RC_BINARY:
                return "rc:binary";
            case FileFormat::TEXT:
                return "text";
            case FileFormat::JSON:
                return "json";
            case FileFormat::PARQUET:
                return "parquet";
            case FileFormat::NIMBLE:
                return "nimble";
            case FileFormat::ORC:
                return "orc";
            case FileFormat::SST:
                return "sst";
            default:
                return "unknown";
        }
    }
} // namespace kumo::pollux::dwio::common
